home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Paginate.ced
- **
- ** $VER: Paginate.ced 1.0 (3.1.95)
- **
- ** This scripts insert page numbers at the bottom of each page in current
- ** file. Number of lines per page must be given explictly as there is no
- ** way to get it from CED.
- ** See docs for more details.
- **
- ** This script requires CygnusEd Professional v3.5 (or later) to run.
- **
- ** Copyright © 1995 Michael Letowski
- */
-
- /* Get host */
- PARSE SOURCE com res called resolved ext host .
- IF host="REXX" THEN /* From command line */
- ADDRESS "rexx_ced" /* Talk to default ced */
-
- OPTIONS RESULTS /* Enable results from commands */
- ARG lpp opt . /* Check for 'FF' option */
-
- /* Set up global variables */
- G.LF="0A"X
- IF DataType(lpp,"N") THEN /* This is number */
- G.LinesPerPage=lpp /* Set to user value */
- ELSE /* Not given or not number */
- G.LinesPerPage=66 /* Set to default value */
- G.Ops=0 /* Number of operations for undo */
- IF opt="FF" THEN G.FF="0C"X /* Option given */
- ELSE G.FF="0A"X /* Option not given */
-
- 'Status CURSORCOLUMN' /* Get current cursor column */
- Column=RESULT+1
- 'Status CURSORLINE' /* Get current cursor line */
- Line=RESULT+1
-
- 'Status RIGHTBORDER' /* Get number of line chars */
- G.CharsPerLine=RESULT
-
- 'Status NUMLINES' /* Get number of lines in file */
- NumLines=RESULT
-
- NumPages=NumLines%(G.LinesPerPage-2) /* Compute number of pages */
- LastLines=G.LinesPerPage-NumLines//(G.LinesPerPage-2)-2
-
- 'DM "Paginating..."' /* Let the user know what's going on */
- DO I=1 TO NumPages /* For each page... */
- CALL InsPageNum(I) /* Insert pagination */
- END
-
- 'End of file' /* Go to end */
- 'Text' Copies(G.LF,LastLines) /* Insert blank lines */
- G.Ops=G.Ops+RESULT
- CALL InsPageNum(NumPages+1) /* Insert last pagination */
-
- CALL SetClip(UndoClipName(),G.Ops) /* Set data for Undo.ced */
-
- 'DM' /* Restore status line */
- 'LL' Line Column /* Restore cursor position */
-
- EXIT
-
- InsPageNum: PROCEDURE EXPOSE G. /* Procedure to insert page number */
- ARG pageNum
- 'LL' pageNum*G.LinesPerPage-1 1
- 'Text' G.LF||Strip(Center("-" pageNum "-",G.CharsPerLine),"T")||G.FF
- G.Ops=G.Ops+RESULT
- RETURN
-
- UndoClipName:
- 'Status FILEMEM' /* Get address of current file */
- RETURN "CEDUndo."Right(D2X(RESULT),8,"0") /* Prepare unique name */
-